class Solution {
    public boolean isPalindrome(String s) {
        s = s.toLowerCase();

        int left = 0;
        int right = s.length() - 1;

        while(left < right){
            while(left < right && !isCharNum(s.charAt(left))){
                left ++;
            }
            while(left < right && !isCharNum(s.charAt(right))){
                right --;
            }
            if(s.charAt(left) == s.charAt(right)){
                left ++;
                right --;
            }else{
                return false;
            }
        }
        return true;
    }
    private boolean isCharNum(char ch){
        if(Character.isDigit(ch) || Character.isLetter(ch)){
            return true;
        }
        return false;
    }
}